package utils;

import java.text.NumberFormat;


public class NombreUtils {
	public static String superieur(String aChaine) {
		aChaine = aChaine.toUpperCase();
		for (int i = aChaine.length() - 1; i >= 0; i--) {
			char c = aChaine.charAt(i);
			if (c != '9') {
				c++;
				return replaceCharAt(aChaine, i, c);
			} else {
				aChaine = replaceCharAt(aChaine, i, '0');
				if (i == 0) {
					aChaine = "1" + aChaine;
				}
			}
		}
		return aChaine;
	}
	
	private static String replaceCharAt(String s, int pos, char c) {
		return s.substring(0, pos) + c + s.substring(pos + 1);
	}
	
	public static String decimaleConverter(Double aNumero){
		NumberFormat nf = NumberFormat.getInstance();
		nf.setMinimumIntegerDigits(1);
		nf.setMinimumFractionDigits(2);
		nf.setMaximumFractionDigits(2);
		nf.setGroupingUsed(false);
		String numberAsString = nf.format(aNumero);
		return numberAsString;
	}
	
}
